//通用部分

const Mock = require('mockjs');
const fs = require('fs');
const path = require('path');

const articleSchema = require('../../schemas/articleSchema.js');//文章表
const typeSchema = require('../../schemas/typeSchema.js');//分类表
const tagSchema = require('../../schemas/tagSchema.js');//tag标签表

//获取web的tags
exports.getWebTags = async cxt=>{
	let data= GetWebTags();
	data.sort((a,b)=>a.id - b.id);
	cxt.body = {
		data
	}
};
//获取web的文章分类
exports.getWebTypes = async ctx=>{
	let types = GetWebTypes();
	types = types.sort((a,b)=>a.id - b.id);
	ctx.body = {
		data:types
	}
};



function GetWebTypes(){
	let result = fs.readFileSync('./data/requiredJSON/webTypes.json');
	let types = JSON.parse(result.toString());
	return types;
}
function GetWebTags(){
	let result = fs.readFileSync('./data/requiredJSON/webTags.json');
	let tags = JSON.parse(result.toString());
	return tags;
}